<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/FoodSageTemplate.xhtml">

    <ui:define name="logout">
        <p:commandLink id="logoutLink" actionListener="#{touristLogoutManagedBean.doLogout}" value="#{bundle['login.logout.label']}" ajax="false" immediate="true" />
    </ui:define>

    <ui:define name="main_menu">
        <f:view beforePhase="#{itineraryChooseItineraryTypeManagedBean.initView}"/>
        <p:menubar model="#{itineraryChooseItineraryTypeManagedBean.touristMainMenuModel}"/>
    </ui:define>

    <ui:define name="nav_menu">
        <p:menu model="#{itineraryChooseItineraryTypeManagedBean.touristNavMenuModel}"/>
    </ui:define>

    <ui:define name="content">
        <f:view beforePhase="#{purchaseGrouponManagerBean.initVisitorMakeOrder}"></f:view>
        <h:form id="form1">
            <p:growl id="growl" showDetail="true" />
            <br/>              
            <br/>
            <f:view>
                <h:outputText rendered="#{!purchaseGrouponManagerBean.showLoginPanel}" value="You are logged in as #{purchaseGrouponManagerBean.tourist.tourist.firstName} #{purchaseGrouponManagerBean.tourist.tourist.lastName}" style="font-weight:bold; font-size:14px"/>
                <p:fieldset style="position:relative; width:950px">
                    <h2>YOUR ORDER</h2>
                    <br/>
                    <h:panelGrid columns="6" cellpadding="5" frame="above" style="text-align:left">
                        <h:outputText value="Description" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="Amount" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="Single Amount" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="Total Amount" style="font-weight:bold; font-size:12px"/>

                        <h:outputText value="#{purchaseGrouponManagerBean.selectedGroupon.groupon.name}" style="font-weight:bold; font-size:12px"/>
                        <h:selectOneMenu value="#{purchaseGrouponManagerBean.purchase.quantity}" id="quantity" >
                            <f:selectItem itemLabel="1" itemValue="1"></f:selectItem>
                            <f:selectItem itemLabel="2" itemValue="2"></f:selectItem>
                            <f:selectItem itemLabel="3" itemValue="3"></f:selectItem>
                            <f:selectItem itemLabel="4" itemValue="4"></f:selectItem>
                            <f:selectItem itemLabel="5" itemValue="5"></f:selectItem>
                            <f:selectItem itemLabel="6" itemValue="6"></f:selectItem>
                            <f:selectItem itemLabel="7" itemValue="7"></f:selectItem>
                            <f:selectItem itemLabel="8" itemValue="8"></f:selectItem>
                            <f:selectItem itemLabel="9" itemValue="9"></f:selectItem>
                            <f:selectItem itemLabel="10" itemValue="10"></f:selectItem>
                            <f:selectItem itemLabel="11" itemValue="11"></f:selectItem>
                            <f:selectItem itemLabel="12" itemValue="12"></f:selectItem>
                            <f:selectItem itemLabel="13" itemValue="13"></f:selectItem>
                            <f:selectItem itemLabel="14" itemValue="14"></f:selectItem>
                            <f:selectItem itemLabel="15" itemValue="15"></f:selectItem>
                            <f:selectItem itemLabel="16" itemValue="16"></f:selectItem>
                            <f:selectItem itemLabel="17" itemValue="17"></f:selectItem>
                            <f:selectItem itemLabel="18" itemValue="18"></f:selectItem>
                            <f:selectItem itemLabel="19" itemValue="19"></f:selectItem>
                            <f:selectItem itemLabel="20" itemValue="20"></f:selectItem>
                            <f:selectItem itemLabel="21" itemValue="21"></f:selectItem>
                            <f:selectItem itemLabel="22" itemValue="22"></f:selectItem>
                            <f:selectItem itemLabel="23" itemValue="23"></f:selectItem>
                            <f:selectItem itemLabel="24" itemValue="24"></f:selectItem>
                            <f:selectItem itemLabel="25" itemValue="25"></f:selectItem>
                            <f:selectItem itemLabel="26" itemValue="26"></f:selectItem>
                            <f:selectItem itemLabel="27" itemValue="27"></f:selectItem>
                            <f:selectItem itemLabel="28" itemValue="28"></f:selectItem>
                            <f:selectItem itemLabel="29" itemValue="29"></f:selectItem>
                            <f:selectItem itemLabel="30" itemValue="30"></f:selectItem>
                            <p:ajax update="totalAmount" listener="#{purchaseGrouponManagerBean.calculateTotalAmount}" /> 
                        </h:selectOneMenu>
                        <h:outputText value="X" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="$S #{purchaseGrouponManagerBean.selectedGroupon.groupon.offeredPrice}" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="=" style="font-weight:bold; font-size:12px"/>
                        <h:outputText value="$S #{purchaseGrouponManagerBean.totalAmount}" style="font-weight:bold; font-size:12px" id="totalAmount"/>
                    </h:panelGrid>
                    <p:commandButton id="submit" update="form1" value="Submit" action="tourist/VisitorConfirmGrouponOrder?faces-redirect=true" ajax="true" rendered="#{!purchaseGrouponManagerBean.showLoginPanel}" />
                </p:fieldset>
            </f:view>
        </h:form>

        <br/>
        <br/>
        <p:fieldset style="width:950px" rendered="#{purchaseGrouponManagerBean.showLoginPanel}">
            <f:view>
                <h:form id="form2">
                    <h2>ALREADY A MEMBER ?</h2>
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="/images/buttons/ajax-loader-bar1.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />
                    <h:panelGrid id="loginPanel" columns="5" cellpadding="10">
                        <h:outputText value="Username" style="font-weight:bold; font-size:12px"/>
                        <p:inputText id="visitorUsername" required="true" requiredMessage="Please provide your username" value="#{purchaseGrouponManagerBean.username}"/>
                        <h:outputText value="Password" style="font-weight:bold; font-size:12px"/>
                        <h:inputSecret id="visitorPassword" required="true" requiredMessage="Please enter your password" value="#{purchaseGrouponManagerBean.password}"/>
                        <p:commandButton id="loginButton" update="form2" value="Log in" actionListener="#{purchaseGrouponManagerBean.loginVistor}" ajax="true" />                          
                    </h:panelGrid>
                </h:form>
            </f:view>
        </p:fieldset>
    </ui:define>
</ui:composition>